/*
 * OpenSCAD File with the code to draw a part of the quadcopter in 3D
 * Part Number: 03
 * Version: 0.01
 * Units: mm
 * Last Modification: Sun Jun 27 23:06:34 WEST 2010
 *
 * Copyright (C) 2010 Henrique Dias <henrique.ribeiro.dias@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

// holes xyz = 15
frominclude = 0;

module p3_subcomponent()
{
	// holes for x, y, z cylinder
	for (pos = [[0, 90, 0], [-90, 0, 0], [0, 0, 0]]) {
		rotate(a = pos) {
			translate(v = [0, 0, 15/2+5]) {
				cylinder(h=15, r=2, center=true, $fn=60);
			}
		}
	}
	// xy cylinder hole
	rotate(a=[90, 0, -45]) {
		cylinder(h=20, r=2, center=true, $fn=60);
	}
	// rings holes
	rotate(a=[90,0,-90-45]) {
		// top
		translate(v = [3.25+2, 20-3.25, 0]) {
			cylinder(h=3, r=1.25, center=true, $fn=60);
		}
		// bottom
		translate(v = [3.25+2, 3.25+2, 0]) {
			cylinder(h=3, r=1.25, center=true, $fn=60);
		}
	}
}


module p3_addcomponent()
{
	// x cylinder
	rotate(a=[0,90,0]) {
		translate(v = [0, 0, 20/2]) {
			cylinder(h=20, r=4, center=true, $fn=60);
		}
		translate(v = [0, 0, 20/2]) {
			cube(size = [8, 2, 20], center=true);
		}
	}
	// y cylinder
	rotate(a=[-90,0,0]) {
		translate(v = [0, 0, 20/2]) {
			cylinder(h=20, r=4, center=true, $fn=60);
		}
		translate(v = [0, 0, 20/2]) {
			cube(size = [2, 8, 20], center=true, $fn=60);
		}
	}
	// z cylinder
	rotate(a=[0,0,90]) {
		translate(v = [0, 0, 20/2]) {
			cylinder(h=20, r=4, center=true, $fn=60);
		}
	}
	// xy cylinder
	rotate(a=[90,0,-45]) {
		cylinder(h=20, r=4, center=true, $fn=60);
		translate(v = [0, 0, 0]) {
			cube(size = [2, 8, 20], center=true);
		}
	}
	// support for the rings
	rotate(a=[0, 0, 90+45]) {
		translate(v = [0, (4+1.25)/2, (20+8/2)/2-8/2]) {
			cube(size = [2, 4+1.25, 20+8/2], center=true);
		}
	}
	// rings
	rotate(a=[90, 0, -90-45]) {
		// top
		translate(v = [3.25+2, 20-3.25, 0]) {
			cylinder(h=2, r=3.25, center=true, $fn=60);
		}
		// bottom
		translate(v = [3.25+2, 3.25+2, 0]) {
			cylinder(h=2, r=3.25, center=true, $fn=60);
		}
	}
	// central cylinder
	rotate(a=[0,0,0]) {
		translate(v = [0, 0, 0]) {
			cylinder(h=8, r=4.5, center=true, $fn=60);
		}
	}
}

module part03()
{
	difference() {
		union() {
			p3_addcomponent();
		}
		p3_subcomponent();
	}
}

if(frominclude == 0) {
	part03();
}
